#!/usr/bin/env python

import wx
import component

class Main(component.Interactor):
    '''Main class
    
    @author Julot <andy.julot@gmail.com>
    @since Saturday, January 14, 2012. 09:04 AM'''
    
    def bind(self):
        super(Main, self).bind()
        
        view = self.view
        menu = view.MenuBar
        tool = view.ToolBar
        
        view.Bind(wx.EVT_MENU, self.open, menu.file.open)
        view.Bind(wx.EVT_MENU, self.close, menu.file.close)
        view.Bind(wx.EVT_MENU, self.showAbout, menu.help.about)
        
        view.Bind(wx.EVT_MENU, self.open, tool.open.tool)
        view.Bind(wx.EVT_MENU, self.close, tool.close.tool)
        view.Bind(wx.EVT_MENU, self.showAbout, tool.about.tool)
        view.Bind(wx.EVT_SCROLL_CHANGED, self.zoom, tool.zoom)
        
        view.canvas.Bind(wx.EVT_MOUSE_EVENTS, self.onMouse)
        view.canvas.Bind(wx.EVT_MOUSEWHEEL, self.onMouseWheel)
        
        tool.color.Bind(wx.EVT_LEFT_UP, self.changeColor, tool.color)
        
    def close(self, event):
        self.presenter.close()
        event.Skip()
    
    def showAbout(self, event):
        self.presenter.showAbout()
        event.Skip()
    
    def onMouse(self, event):
        self.presenter.onMouse(event)
    
    def onMouseWheel(self, event):
        self.presenter.onMouseWheel(event)
    
    def open(self, event):
        self.presenter.open()
    
    def changeColor(self, event):
        self.presenter.changeCropColor()
    
    def zoom(self, event):
        self.presenter.show()
